<table id="list" class="scroll"></table>
<div id="pager" class="scroll" style="text-align:center;"></div>

<div id="permsDialog" title="Group Permissions">
	<p>
		<span class="ui-icon ui-icon-circle-check" style="float:left; margin:0 7px 50px 0;"></span>
		Please Select Group for edit permissions!
	</p>
</div>

<script type="text/javascript">
jQuery('#list').jqGrid({
	url:'/usergroups/list/format/json',
	datatype: 'json',
	mtype: 'GET',
	colNames:['Id','Title'],
	colModel :[
	  {name:'USERGROUPS_ID', index:'USERGROUPS_ID', sorttype:'int', width:50},
	  {name:'USERGROUPS_TITLE', index:'USERGROUPS_TITLE', width:450, editable:true} ],
	pager: jQuery('#pager'),
	rowNum:20,
	rowList:[20, 40, 60, 80, 100, 150, 200],
	sortname: 'USERGROUPS_ID',
	sortorder: 'asc',
	viewrecords: true,
	caption: 'User Groups View',
	width:900,
	editurl: "/usergroups/edit"
}).navGrid('#pager',{
	edit:true,add:true,del:true,search:true
}).navButtonAdd('#pager',{
	caption:"Group Permissions", onClickButton: function(id){
		var gr = jQuery("#list").getGridParam("selrow");
		if( gr != null ) {
			document.location.href = '/usergroups/rights/id/' + gr;
		} else {
			$("#permsDialog").dialog('open')
		}
	},
	position:"last"
});

$("#permsDialog").dialog({
	bgiframe: true,
	modal: true,
	autoOpen: false,
	buttons: {
		Ok: function() {
			$(this).dialog('close');
		}
	}
});
</script>
